package com.itsv.cyzx.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itsv.cyzx.bean.SuggestBean;
import com.itsv.xhyy.R;

public class SuggetsListAdapter extends BaseAdapter {

	private Context con = null;
	private ArrayList<SuggestBean> jlist = null;
	private HashMap<Integer, View> viewCache = null;
	private LayoutInflater inflater;

	public SuggetsListAdapter(Context con, ArrayList<SuggestBean> jlist) {
		this.con = con;
		this.jlist = jlist;
		viewCache = new HashMap<Integer, View>();
		this.inflater = LayoutInflater.from(this.con);
	}

	public void setData(ArrayList<SuggestBean> jlist) {
		this.jlist = jlist;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return jlist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View cv = viewCache.get(position);
		if (cv == null) {
			cv = inflater.inflate(R.layout.suggest_listitem, null);
			SuggestBean mm = jlist.get(position);
			TextView title = (TextView) cv.findViewById(R.id.text_suggest_title);
			TextView time = (TextView) cv.findViewById(R.id.text_suggest_time);
			title.setText(mm.getTITLE());
			time.setText(mm.getSUBMIT_TIME());
			viewCache.put(position, cv);
			return cv;
		} else {
			return cv;
		}

	}

}
